<!DOCTYPE html>
<html class="no-touch">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>专栏设置</title>
    <meta name="fragment" content="!">
    <meta name="description" content="知乎专栏">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="address=no">
    <script src="/homeCSS/zhuanlanCSS/ga.js" async=""></script>
    <script>document.documentElement.className += ('ontouchstart' in window) ? ' touch' : ' no-touch'</script>
    <link rel="stylesheet" href="/homeCSS/zhuanlanCSS/573ac0fc.css">
    <meta name="baidu-site-verification" content="U9zXUx8bxm">
</head>
  <body class="ng-scope">
    <main class="main-container ng-scope" ng-view="">
        <div class="main receptacle column-settings ng-scope">

  <div class="tabs">
    <div class="ng-scope">
        <div class="tabs-nav clearfix ng-scope" ng-controller="ColumnEditNavCtrl">
            <h1>专栏设置</h1>
        </div>
    </div>
  </div>
@foreach($data as $k=>$v)
<form action="/home/zhuanlan/update" method="post" enctype="multipart/form-data">
    {{ csrf_field() }}
  <div class="setting-container">
    <div class="column-form" novalidate="">
        @if($v->zlpic)
        <img src="{{$v->zlpic}}" class="ColumnAbout-avatar" alt="" style="width:200px;height:200px;">
        @else    
        <img src="/homeCSS/img/1.jpg" class="ColumnAbout-avatar" alt="" style="width:100px;height:100px;">
        @endif
        <input name="zlpic" type="file">
        <input type="hidden" name="id" value="{{$v->id}}"/> 
        <input type="submit" class="btn btn-green btn-90_32" value="修改">
    </div>
    
  </div>
</form>

    <div class="basic-info setting-sec ng-pristine ng-valid ng-valid-required" ng-form="columnNameForm">
        <div class="form-title with-margin">专栏名</div>
        <div class="form-content ng-scope ng-pristine ng-valid" ui-form-linkage="" ng-model="column.name">
          <div class="name">
            <input type="hidden" class="zlid" value="{{$v->id}}">
            <input required="" value="{{$v->cname}}" name="cname" class="mui-input" placeholder="填写专栏名字" max-width="368" word-max="20" ng-disabled="column.pendingName" style="width: 368px;">
            <div class="tips-always" style="color:red;display:none">
              专栏名已存在!
            </div>
            <div class="ti ps" ng-show="!column.pendingName" style="width: 368px;">
              <div class="right" style="display:none;float:right;color:red">专栏名不能为空</div>
              
            </div>
            <div class="save-btn" ng-show="!column.pendingName">
              <button class="btn btn-grey-nborder btn-72_32">取消</button>
              <button class="btn btn-blue btn-72_32" disabled >保存</button>
            </div>
          </div>
        </div>
      </div>
@endforeach
</main>
    <script src="/homeCSS/zhuanlanCSS/8e93f487.js"></script>
    <script src="/homeCSS/zhuanlanCSS/eac22011.js"></script>
    <script src="/homeCSS/zhuanlanCSS/21ba3a5f.js"></script>
    <script src="/homeCSS/zhuanlanCSS/zap.js"></script>
    <script type="text/javascript">
        //获取原专栏名
        var oldname = $('.mui-input').val();
        var cname = '';

        //绑定单击事件
        $('.btn-grey-nborder').click(function(){
        //还原原来的专栏名
            $('.mui-input').val(oldname);
            $('.right').hide();
            $('.btn-blue').attr('disabled','disabled');
        })
        //绑定keyup事件
        $('.mui-input').keyup(function(){
            
            //获取专栏名
            cname = $('.mui-input').val();
            //判断是否改名
            if(cname==oldname){
                $('.btn-blue').attr('disabled','disabled');
                $('.tips-always').hide();
            }else if(!cname){
            
                $('.right').show();
            }else{
                $('.btn-blue').removeAttr('disabled');
                $('.right').hide();
                $.get('/home/zhuanlan/zlmcx',{cname:cname},function(data){
                    if(data==1){
                        $('.tips-always').show();
                    }else if(data==2){
                        $('.tips-always').hide();
                    }
                }); 
            }
        })

        //绑定单击事件
        $('.btn-blue').click(function(){
            //获取专栏id
            var id = $('.zlid').val();
            $.get('/home/zhuanlan/zlmxg',{cname:cname,id:id},function(data){
                //判断是否执行成功
                if(data==1){
                    alert('修改成功');
                    $('.btn-blue').attr('disabled','disabled');
                }else if(data==2){
                    alert('修改失败');
                }
            })
        })


    </script>
</body>
</html>